//
//  NewsTableViewCell.m
//  XinKaiFa55like
//
//  Created by junseek on 2017/1/16.
//  Copyright © 2017年 55like lj. All rights reserved.
//

#import "NewsTableViewCell.h"


@interface NewsTableViewCell (){    //
    
    NSIndexPath *tempIndexPath;
    NSDictionary *tempDic;
    
    UIImageView *imageIcon;
    UILabel *lblTitle;
    UILabel *lblContent;
    UILabel *lblDate;
    UIView *viewLine;
    UIImageView *imageRedV;
}

@end
@implementation NewsTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView * BGV=[[UIView alloc]initWithFrame:self.bounds];
        [BGV setBackgroundColor:RGBCOLOR(255, 255, 255)];
        [self setBackgroundView: BGV];
        
        imageIcon=[RHMethods imageviewWithFrame:CGRectMake(10, 10, 70, 70) defaultimage:@"newPic"];
        [self addSubview:imageIcon];
        
        lblTitle=[RHMethods labelWithFrame:CGRectMake(90, 10, kScreenWidth-105, 20) font:fontTitle color:rgbTitleColor text:@""];
        [self addSubview:lblTitle];
        
        lblContent=[RHMethods labelWithFrame:CGRectMake(X(lblTitle), YH(lblTitle)+2, W(lblTitle), 35) font:fontTxtContent color:rgbTxtDeepGray text:@""];
        [self addSubview:lblContent];
        
        lblDate =[RHMethods labelWithFrame:CGRectMake(X(lblTitle), YH(lblContent), W(lblTitle), 15) font:fontSmallTitle color:rgbTxtGray text:@""];
        [self addSubview:lblDate];
        
        viewLine=[RHMethods lineViewWithFrame:CGRectMake(0, 90, kScreenWidth, 5)];
        [self addSubview:viewLine];
        viewLine.backgroundColor=rgbGray;
        imageRedV=[RHMethods imageviewWithFrame:CGRectMake(XW(lblTitle), 7, 10, 10) defaultimage:@"redTip070116" contentMode:UIViewContentModeCenter];
        [self addSubview:imageRedV];
        imageRedV.hidden=YES;
        [self setSelectionStyle:UITableViewCellSelectionStyleNone];
    }
    return self;
}

//内容更新
-(void)setValueForDictionary:(NSDictionary *)dic indexPath:(NSIndexPath *)indexPath type:(NSString *)strType{
    tempIndexPath=indexPath;
    tempDic=dic;
    
    
    
//    if ([strType isEqualToString:@"log"]) {
//        [imageIcon imageWithURL:[dic valueForJSONStrKey:@"path"] useProgress:NO useActivity:NO];
//        
//        return;
//    }
    
    [imageIcon imageWithURL:[dic valueForJSONStrKey:@"path"] useProgress:NO useActivity:NO];
    lblTitle.text=[dic valueForJSONStrKey:@"title"];
    lblContent.text=[dic valueForJSONStrKey:@"descr"];
    lblDate.text=[[Utility Share] timeToTimestamp:[dic valueForJSONStrKey:@"ctime"]];
    if ([strType isEqualToString:@"newslog"]) {
        
        lblDate.text=[dic valueForJSONStrKey:@"createtime"];
    }
    
    if ([strType isEqualToString:@"Extension"]) {
        viewLine.frameHeight=0.5;
    }else if ([strType isEqualToString:@"companyNotice"]){
        imageRedV.hidden=![[dic valueForJSONStrKey:@"isred"] isEqualToString:@"0"];
    }else if ([strType isEqualToString:@"news"]){
        imageRedV.hidden=![[dic valueForJSONStrKey:@"isred"] isEqualToString:@"0"];
    }
  
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
